﻿using System;
using System.Web;
using System.Web.Mvc;
using ScrumLite.Services;
using ScrumLite.WebUx.Models;
using ScrumLite.Services.Contracts;
using System.Collections.Generic;
using ScrumLite.Gateways;
using System.Collections.ObjectModel;

namespace ScrumLite.WebUx.Controllers
{
    public class MeasuresController : ContextBaseController
    {

        private IMeasuresService Measures;

        public MeasuresController():this(new MeasuresServiceClient(), new ProjectsServiceClient())
        { 
        }

        public MeasuresController(IMeasuresService measureService, IProjectsService projectService)
        { 
            this.Projects = projectService;
            this.Measures = measureService;
        }

        public void Dashboard(string projectId, string processName)
        {
            MeasuresListViewData viewData;

            Measure[] measures = this.Measures.GetMeasuresByProcessName(new Guid(projectId), processName);

            if (measures != null)
            {
                viewData = new MeasuresListViewData(new Collection<Measure>(measures));
            }
            else
            {
                viewData = new MeasuresListViewData();
            }

            viewData.ProjectName = "SSA";
            viewData.ProcessName = processName;

            RenderView("Dashboard", viewData);
        }

        public void Description()
        {
            RenderView("Description");
        }
    }
}
